home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 2 / Atari Mega Archive CD - Volume 2.iso / 8bit / cislib_a / entryc.act < prev    next >
Text File  |  1995-04-22  |  3KB  |  160 lines

  1. ;************************************
  2. ;*                                  *
  3. ;*(C)Copyright 1986 by Paul B. Loux *
  4. ;*                                  *
  5. ;* These routines are in the public *
  6. ;* domain,  and  are not to be sold *
  7. ;* for a profit. They may be freely *
  8. ;* distributed, provided  that this *
  9. ;* header remains in place. Use and *
  10. ;* enjoy! PBL, CIS 72337,2073.      *
  11. ;*                                  *
  12. ;************************************
  13. ;
  14. ;  CARD FUNC EntryC()
  15. ;
  16. ;  Universal card-entry routine,
  17. ;  requires PROC EntryS(), the
  18. ;  universal string entry routine.
  19. ;  Includes range check, execute
  20. ;  on first digit flag, a null-
  21. ;  entry ok flag, and uses the
  22. ;  the same XIT flag as ENTRYS.
  23. ;
  24. ;  This routine takes input from
  25. ;  K: in string form (through
  26. ;  EntryS) and checks for legal
  27. ;  value (<=65535) and other useful
  28. ;  features before converting to
  29. ;  an actual CARD value.
  30. ;
  31. ;  Includes range check, execute
  32. ;  on single digit flag, a null-
  33. ;  entry ok flag, and uses the
  34. ;  the same xit flag as EntryS.
  35. ;  Use of EntryS allows the same
  36. ;  user interface (ESC and ^-Z
  37. ;  handling, timeouts, etc.)
  38. ;
  39. ;  Parameters are self-explanatory;
  40. ;  minval and maxval are the range
  41. ;  limits for acceptable response
  42. ;  (limted to 0-65535 of course);
  43. ;  the XEQ, XIT and nullok flags
  44. ;  are 1 or yes and 0 for no.
  45. ;
  46. ;************************************
  47. ;
  48.  INCLUDE "ENTRYS.ACT"
  49. ;
  50. ;************************************
  51.  
  52. CARD FUNC EntryC(BYTE col,row
  53.                  CARD minval,maxval
  54.                  BYTE nullok,
  55.                  xeq,xit
  56.                  BYTE POINTER err_ptr)
  57.  
  58. BYTE ARRAY limit(0)="65535",
  59.            field(0)="....." 
  60. BYTE fldlen=field
  61.  
  62. BYTE accept,min,max,typec
  63. CARD value
  64. INT chk
  65.  
  66. min=1
  67. IF minval>10 THEN min==+1 FI
  68. IF minval>100 THEN min==+1 FI
  69. IF minval>1000 THEN min==+1 FI
  70. IF minval>10000 THEN min==+1 FI
  71. IF nullok THEN
  72.  min=0 
  73. FI
  74.  
  75. IF maxval=0 THEN
  76.  maxval=65535
  77.  max=5
  78. ELSE
  79.  max=1
  80.  IF maxval>10 THEN max==+1 FI
  81.  IF maxval>100 THEN max==+1 FI
  82.  IF maxval>1000 THEN max==+1 FI
  83.  IF maxval>10000 THEN max==+1 FI
  84. FI
  85.  
  86. typec=5               ; pos int
  87. accept=0
  88. chk=0
  89.  
  90. DO
  91.  ENTRYS(field,min,max,typec,xit,
  92.         col,row,err_ptr)
  93.        
  94.  IF err_ptr^#0 THEN RETURN(0) FI
  95. ;Calling routine does error handling
  96.  
  97.  IF fldlen=0 THEN
  98.   field(1)='0
  99.   field(0)=1
  100.  FI
  101.  
  102.  IF fldlen=5 THEN
  103.   chk=SCOMPARE(field,limit)
  104.  FI
  105.  IF chk>0 THEN
  106.   chk=0
  107.   MSG(7)
  108.  ELSE
  109.   value=VALC(field)
  110.   IF value<minval OR value>maxval
  111.    THEN MSG(7)
  112.   ELSE accept=1
  113.   FI
  114.  FI
  115.  
  116. UNTIL accept
  117. OD
  118.  
  119. RETURN(value)
  120.  
  121. ;************************************
  122. ;
  123. ; Example of use of EntryC()
  124.  
  125. PROC Test3()
  126.  
  127. BYTE x,y,nullflg
  128. CARD min,max,value
  129. BYTE errcde
  130. BYTE POINTER err_ptr
  131.  
  132. errcde=0
  133. err_ptr=@errcde
  134.  
  135. min=1000
  136. max=2000
  137.  
  138. nullflg=0
  139. x=17  y=7
  140.  
  141. PUT(125)
  142. POSITION(5,5)
  143. PUTE()
  144. PRINTE("Enter a number between ")
  145. PRINTC(min)
  146. PRINT(" and ")
  147. PRINTC(max)
  148. PRINT(": ")
  149.  
  150. value=EntryC(x,y,min,max,nullflg,
  151.              0,0,err_ptr)
  152.  
  153. POSITION(5,10)
  154. PUTE()
  155. PRINTCE(value)
  156. PRINTE("Done...")
  157.  
  158. RETURN
  159.  
  160.